import collections


class Solution(object):
    def bonus(self, n, leadership, operations):
        d = collections.defaultdict(set)
        base = 10 ** 9 + 7
        bianhao = {}
        count = {}
        self.index = 0
        for u, v in leadership:
            d[u].add(v)

        def dfs(u):
            bianhao[u] = self.index
            self.index += 1
            child = 0
            for v in d[u]:
                child += dfs(v)
            count[u] = child + 1
            return count[u]

        dfs(1)
        s = [0] * 4 * n
        flag = [0] * 4 * n

        def down(node, ls, rs):
            s[node] = (s[node] + flag[node] * (rs - ls + 1)) % base
            if ls != rs:
                flag[2 * node + 1] += flag[node]
                flag[2 * node + 2] += flag[node]
            flag[node] = 0

        def update_1(node, ls, rs, u, val):
            if ls == rs:
                s[node] += val
            else:
                down(node, ls, rs)
                mid = (ls + rs) // 2
                if u <= mid:
                    update_1(2 * node + 1, ls, mid, u, val)
                if u >= mid + 1:
                    update_1(2 * node + 2, mid + 1, rs, u, val)
                s[node] = (s[2 * node + 1] + s[2 * node + 2] + flag[2 * node + 1] * (mid - ls + 1) + flag[
                    2 * node + 2] * (rs - mid)) % base

        def update_2(node, ls, rs, l, r, val):
            if l <= ls and rs <= r:
                flag[node] += val
            else:
                down(node, ls, rs)
                mid = (ls + rs) // 2
                if l <= mid:
                    update_2(2 * node + 1, ls, mid, l, r, val)
                if r >= mid + 1:
                    update_2(2 * node + 2, mid + 1, rs, l, r, val)
                s[node] = (s[2 * node + 1] + s[2 * node + 2] + flag[2 * node + 1] * (mid - ls + 1) + flag[
                    2 * node + 2] * (rs - mid)) % base

        def query(node, ls, rs, l, r):
            if l <= ls and rs <= r:
                return s[node] + flag[node] * (rs - ls + 1)
            else:
                down(node, ls, rs)
                mid = (ls + rs) // 2
                ans = 0
                if l <= mid:
                    ans += query(2 * node + 1, ls, mid, l, r)
                if r >= mid + 1:
                    ans += query(2 * node + 2, mid + 1, rs, l, r)
                return ans % base

        ans = []
        for op in operations:
            if len(op) == 3:
                if op[0] == 1:
                    u = bianhao[op[1]]
                    update_1(0, 0, n - 1, u, op[2])
                if op[0] == 2:
                    l = bianhao[op[1]]
                    r = l + count[op[1]] - 1
                    update_2(0, 0, n - 1, l, r, op[2])
            else:
                l = bianhao[op[1]]
                r = l + count[op[1]] - 1
                ans.append(query(0, 0, n - 1, l, r))
        return ans
#不带懒标记
# class Solution(object):
#     def bonus(self, n, leadership, operations):
#         d = collections.defaultdict(set)
#         bianhao = {}
#         count = {}
#         base = 10 ** 9 + 7
#         self.index = 0
#         for u, v in leadership:
#             d[u].add(v)
#
#         def dfs(u):
#             bianhao[u] = self.index
#             self.index += 1
#             child = 0
#             for v in d[u]:
#                 child += dfs(v)
#             count[u] = child + 1
#             return count[u]
#
#         dfs(1)
#         s = [0] * 4 * n
#
#         def update_1(node, ls, rs, u, val):
#             if ls == rs:
#                 s[node] += val
#             else:
#                 mid = (ls + rs) // 2
#                 if u <= mid:
#                     update_1(2 * node + 1, ls, mid, u, val)
#                 if u >= mid + 1:
#                     update_1(2 * node + 2, mid + 1, rs, u, val)
#                 s[node] = (s[2 * node + 1] + s[2 * node + 2]) % base
#
#         def update_2(node, ls, rs, l, r, val):
#             if ls == rs:
#                 s[node] += val
#             else:
#                 mid = (ls + rs) // 2
#                 if l <= mid:
#                     update_2(2 * node + 1, ls, mid, l, r, val)
#                 if r >= mid + 1:
#                     update_2(2 * node + 2, mid + 1, rs, l, r, val)
#                 s[node] = (s[2 * node + 1] + s[2 * node + 2]) % base
#
#         def query(node, ls, rs, l, r):
#             if l <= ls and rs <= r:
#                 return s[node]
#             else:
#                 mid = (ls + rs) // 2
#                 ans = 0
#                 if l <= mid:
#                     ans += query(2 * node + 1, ls, mid, l, r)
#                 if r >= mid + 1:
#                     ans += query(2 * node + 2, mid + 1, rs, l, r)
#                 return ans % base
#
#         ans = []
#         for op in operations:
#             if len(op) == 3:
#                 if op[0] == 1:
#                     u = bianhao[op[1]]
#                     update_1(0, 0, n - 1, u, op[2])
#                 if op[0] == 2:
#                     l = bianhao[op[1]]
#                     r = l + count[op[1]] - 1
#                     update_2(0, 0, n - 1, l, r, op[2])
#             else:
#                 l = bianhao[op[1]]
#                 r = l + count[op[1]] - 1
#                 ans.append(query(0, 0, n - 1, l, r))
#         return ans

data = Solution()
n = 8
leadership = [[1, 2], [1, 6], [2, 3], [2, 5], [1, 4], [6, 7], [6, 8]]
operations = [[2, 1, 10], [3, 1]]
print(data.bonus(n, leadership, operations))
